//
//  YLCBannerView.m
//  LinYa
//
//  Created by Fancy on 2018/6/21.
//  Copyright © 2018年 初程程. All rights reserved.
//

#import "YLCBannerView.h"

@interface YLCBannerView ()
{
    UIImageView *bottomImageView;
}
@end

@implementation YLCBannerView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.userInteractionEnabled = YES;
        [self createCustomViews];
    }
    return self;
}
- (void)setBannerModel:(YLCBannerModel *)bannerModel{
    _bannerModel = bannerModel;
    
    [bottomImageView sd_setImageWithURL:[NSURL URLWithString:bannerModel.imgsrc]];
}
- (void)createCustomViews{
    bottomImageView = [[UIImageView alloc] init];
        
    [self addSubview:bottomImageView];
    
    [bottomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.equalTo(self).offset(10);
        make.right.and.bottom.equalTo(self).offset(-10);
    }];
    
    _button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [_button setBackgroundImage:[UIImage imageNamed:@"hud_cancel"] forState:UIControlStateNormal];

    [self addSubview:_button];
    
    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-20);
        make.top.equalTo(self).offset(20);
        make.size.equalTo(CGSizeMake(15, 15));
    }];
}
@end
